// pages/product_detail/product_detail.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrls: [
      '../image/index/meinv.png',
      '../image/index/meinv.png',
      '../image/index/meinv.png'
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 3000,
    duration: 800,
    currentSwiper: 0,
    pinggu:false
  },
  swiperChange: function (e) {
    this.setData({
      currentSwiper: e.detail.current
    })
  },
  zhe:function(){
    this.setData({
      pinggu: false
    })
  },
  pinggu_click:function(e){
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.dataset.phone,
    })
  },
  call_kefu:function(e){
    wx.makePhoneCall({
      phoneNumber:'15989041331',
    })
  },
  // 去商品详情
  go_shop_detail: function (e) {
    console.log(e.currentTarget.dataset.id)
    wx.navigateTo({
      url: '../product_detail/product_detail?id=' + e.currentTarget.dataset.id,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.id)
    var that = this;
    // 商品详情
    wx.request({
      url: app.globalData.url + 'ny_flow_goods.php?action=detail',
      data:{
        goods_id:options.id
      },
      success:function(res){
        console.log(res)
        let goods_desc = res.data.goods_desc;
        res.data.goods_desc = goods_desc.replace(/\<img/gi, '<img style="width:100% !important;height:auto!important" ')
        that.setData({
          detail:res.data
        })
      }
    })
    // 商城
    wx.request({
      url: app.globalData.url + 'ziyu.php?Action=product',
      success: function (res) {
        console.log('商城')
        console.log(res)
        that.setData({
          shop_list: res.data
        })
      }
    })

    // 评估人
    wx.request({
      url: app.globalData.url + 'ziyu.php?Action=danzhang&shuzi=6',
      success: function (res) {
      
        console.log(res)
        that.setData({
          pingguren:res.data[0]
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    var that = this;
    return {
      title: that.data.detail.goods_brief,
      path: 'pages/product_detail/product_detail?id=' + that.data.detail.goods_id,
      imageUrl:  that.data.detail.goods_thumb

    }
  }
})